package com.star.security.authentication.wxapp;

import com.star.security.authentication.AuthenticationToken;
import lombok.Getter;
import lombok.Setter;

/**
 * 微信小程序认证
 *
 * @author yangzj
 */
@Setter
@Getter
public class WxappAuthenticationToken extends AuthenticationToken {

    public WxappAuthenticationToken(Object principal, Object credentials, Object detail, Long expiresIn) {
        super(principal, credentials, detail, expiresIn, false);
    }

    /**
     * 未经验证
     *
     * @param credentials code
     * @param expiresIn   有效时间（秒）
     * @param detail       type
     * @return {@link WxappAuthenticationToken}
     */
    public static WxappAuthenticationToken unauthenticated(Object credentials, Object detail, Long expiresIn) {
        return new WxappAuthenticationToken(null, credentials, detail, expiresIn);
    }

    /**
     * 已验证
     *
     * @param principal 用户信息
     * @param expiresIn 有效时间（秒）
     * @return {@link WxappAuthenticationToken}
     */
    public static WxappAuthenticationToken authenticated(Object principal, Long expiresIn) {
        return new WxappAuthenticationToken(principal, null, null ,expiresIn);
    }
}
